package a66weding.com.jiehuntong.adapter;

import android.content.Context;
import android.content.Intent;
import android.graphics.Paint;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import org.w3c.dom.Text;
import org.xutils.x;

import java.util.ArrayList;
import java.util.List;

import a66weding.com.jiehuntong.R;
import a66weding.com.jiehuntong.beans.HomeBotomListBean;
import a66weding.com.jiehuntong.beans.StoreDetailGuess;
import a66weding.com.jiehuntong.common.utils.ImageOptionsUtil;

/**
 * Created by admin on 2016/8/3.
 */
public class StroreAdapter extends BaseAdapter {
    private Context context;
    private List<StoreDetailGuess.DataBean> dataBeen;
    public  StroreAdapter( Context context,List<StoreDetailGuess.DataBean> dataBeen){
        this.context = context;

    }
    @Override
    public int getCount() {
        return dataBeen.size();
    }

    @Override
    public Object getItem(int position) {
        return dataBeen.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    public void appeanData(List<StoreDetailGuess.DataBean> dataBeen){
        if (this.dataBeen!=null){
            this.dataBeen.addAll(dataBeen);

        }
        notifyDataSetChanged();
    }

    public void clear(){
        if (this.dataBeen!=null){
            dataBeen.clear();
        }
        notifyDataSetChanged();
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        ViewHolder hold;
        if (convertView == null){
            hold = new ViewHolder();
            convertView = View.inflate(context, R.layout.item_store_content, null);
            hold.item_store_iv = (ImageView) convertView.findViewById(R.id.item_store_iv);
            hold.item_store_content = (TextView) convertView.findViewById(R.id.item_store_content);
            hold.item_store_tv_num = (TextView) convertView.findViewById(R.id.item_store_tv_num);
            hold.item_store_discount_price = (TextView) convertView.findViewById(R.id.item_store_discount_price);
            hold.item_store_yuanjia = (TextView) convertView.findViewById(R.id.item_store_yuanjia);
            convertView.setTag(hold);
        }else{
            hold = (ViewHolder) convertView.getTag();
        }
        x.image().bind(hold.item_store_iv,dataBeen.get(position).getNvc_PicMain(), ImageOptionsUtil.getOptions316_720());
        hold.item_store_content.setText(dataBeen.get(position).getNvc_Name());
        hold.item_store_tv_num.setText(""+dataBeen.get(position).getI_Moods());
        hold.item_store_discount_price.setText(""+dataBeen.get(position).getDm_ShopPrice());
        hold.item_store_yuanjia.setText(""+dataBeen.get(position).getDm_Price());
        /**
         * textView.getPaint().setFlags(Paint. UNDERLINE_TEXT_FLAG ); //下划线
         　　textView.getPaint().setAntiAlias(true);//抗锯齿
         　　textview.getPaint().setFlags(Paint. STRIKE_THRU_TEXT_FLAG); //中划线
         　　setFlags(Paint. STRIKE_THRU_TEXT_FLAG|Paint.ANTI_ALIAS_FLAG); // 设置中划线并加清晰
         */
        hold.item_store_yuanjia.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG);
        hold.item_store_yuanjia.getPaint().setAntiAlias(true);//抗锯齿
        hold.item_store_yuanjia.getPaint().setFlags(Paint. STRIKE_THRU_TEXT_FLAG);
        return convertView;
    }

    public class ViewHolder{
        //图片;
        ImageView item_store_iv;
        //内容
        TextView item_store_content;
        //多少人收藏;
        TextView item_store_tv_num;
        //现价
        TextView item_store_discount_price;
        //原价
        TextView item_store_yuanjia;
    }
    private List<HomeBotomListBean.DataBean> homebottemlist;
    private  HomeBotomListBean.DataBean homeBean;
    private HomeBotomListBean.DataBean.BusinessBean businessBean;

}
